/**
 * Created by song on 2016/8/17.
 */
//按照评论数排序
function sortByComment(list, upprdown) {
  var lists = list;
  var temp;
  for (var i = 0; i < lists.length; i++) {
    for (var j = 0; j < lists.length - i - 1; j++) {
      if (upprdown) {

        if (parseInt(lists[j].planCount) < parseInt(lists[j + 1].planCount)) {
          temp = lists[j + 1];
          lists[j + 1] = lists[j];
          lists[j] = temp;
        }
      }
      else {
        if (parseInt(lists[j].planCount) > parseInt(lists[j + 1].planCount)) {
          temp = lists[j + 1];
          lists[j + 1] = lists[j];
          lists[j] = temp;
        }
      }
    }
  }
  return lists;
}
///按照发布日期排序
function sortByDate(list, upprdown) {
  var lists = list;
  var temp;
  for (var i = 0; i < lists.length; i++) {
    for (var j = 0; j < lists.length - i - 1; j++) {
      if (upprdown) {

        if (Date.parse(lists[j].create_time) < Date.parse(lists[j + 1].create_time)) {
          temp = lists[j + 1];
          lists[j + 1] = lists[j];
          lists[j] = temp;
        }
      }
      else {
        if (Date.parse(lists[j].create_time) > Date.parse(lists[j + 1].create_time)) {
          temp = lists[j + 1];
          lists[j + 1] = lists[j];
          lists[j] = temp;
        }
      }
    }
  }
  return lists;
}

function getMockMessages() {
  return {
    "messages": [{
      "_id": "535d625f898df4e80e2a125e",
      "type":'1',
      "content": "Ionic has changed the game for hybrid app development.",
      "fromUserName":"马云",
      "date": "2014-04-27T20:02:39.082Z",
      "position": "left"
    }, {
      "_id": "54764399ab43d1d4113abfd1",
      "type":'1',
      "content": "Am I dreaming?",
      "fromUserName":"马云",
      "date": "2014-11-26T21:18:17.591Z",
      "position": "right"
    },  {
      "_id": "546a5843fd4c5d581efa263a",
      "type":'1',
      "content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
      "fromUserName":"王健林",
      "date": "2014-11-17T20:19:15.289Z",
      "position": "left"
    },  {
      "_id": "54781ca4ab43d1d4113abff1",
      "type":'1',
      "content": "Create amazing apps - ionicframework.com",
      "fromUserName":"王健林",
      "date": "2016-06-31 13:02:21",
      "position": "right"
    }], "unread": 0
  };
}
